<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>05 style与css</title>
    <script src="./js/vue.js"></script>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .meau{
            width: 400px;
            height: 40px;
            margin: 50px auto;
        }
        .meau .item{
            width: 100px;
            float: left;
            height: 40px;
            line-height: 40px;
            background-color: navy;
            color: oldlace;
            text-align: center;
        }
        .meau .active{
            color: red;
        }

    </style>
</head>
<body>
    <div id="app">
        <div class="meau">
            <div class="item" :class="{active : item.id==activeIndex}"  v-for="item in list" @click = "reactive(item.id)">{{item.msg}}</div>
      

        </div>
    </div>
    
</body>
<script>
    new Vue({
        el : "#app",
        data : {
            activeIndex : 1,
            list : [{id:1 , msg : "菜单一"} , {id:2 , msg : "菜单二"} , {id:3 , msg : "菜单三"} , {id:4 , msg : "菜单四"}]

        },
        methods : {
            reactive(id){
                this.activeIndex = id;
            }

        }
    })

</script>
</html>